home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / cprint.arc / JZFNDFST.C < prev    next >
Encoding:
Text File  |  1986-01-15  |  1.6 KB  |  35 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │Title   : jzfndfst                                                          │
  4. │Purpose : find the first matching file from a given file spec               │
  5. │Notes:  You must define a directory record from the type TDIR, defined in   │
  6. │        in jzdirect.h                                                       │
  7. │Parms:                                                                      │
  8. │   fmask - i.e. "*.*"                                                       │
  9. │   fattr - file attribute to use for search. use 32 for normal searches     │
  10. │   fdta  - TDIR variables                                                   │
  11. │                                                                            │
  12. │i.e.      error = jzfndfst ( "*.*" , 0x20 , &dir_record )                   │
  13. │Written by Jack Zucker - 75766,1336    301-794-5950  on 1/15/85             │
  14. └────────────────────────────────────────────────────────────────────────────┘
  15. */
  16.  
  17. jzfndfst (fmask,fattr,fdta)
  18. int fmask;
  19. int  fattr;
  20. int fdta;
  21. {
  22.   union REGS  winreg,woutreg;
  23.  
  24.   winreg.x.dx  = fdta;            /* get address of dir record */
  25.   winreg.h.ah  = 0x1a;            /* set dta function */
  26.   intdos(&winreg,&woutreg);
  27.  
  28.   winreg.x.dx  = fmask;
  29.   winreg.h.ah  = 0x4e;            /* find first matching file      */
  30.   winreg.x.cx  = fattr;           /* set file attribute for search */
  31.   intdos(&winreg,&woutreg);
  32.   if (woutreg.x.cflag & 0x0001 == 1) return(woutreg.x.ax);
  33.   else return(0);       /* return 0 if no error, otherwise dos error code */
  34. }
  35.